package com.hong.chapter4;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @Auther: Administrator
 * @Date: 2018/7/17 23:43
 * @Description:
 */
public final  class EncryptUtils {

    public static final byte ENCRYPT_FACTOR = (byte)0xff;

    private EncryptUtils(){
        //empty
    }

    public static void doEncrypt(String source,String target){
        try (FileInputStream fis = new FileInputStream(source);
             FileOutputStream fos = new FileOutputStream(target)){
            int data;
            while ((data=fis.read())!=-1){
                fos.write(data^ENCRYPT_FACTOR);
            }

        }catch (FileNotFoundException e){
            e.printStackTrace();

        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        doEncrypt("C:\\Users\\Administrator\\IdeaProjects\\classLoader\\src\\main\\java\\com\\hong\\chapter4\\test\\MyClassLoaderTest.class","C:\\Users\\Administrator\\IdeaProjects\\classLoader\\src\\main\\java\\com\\hong\\chapter4\\test\\MyClassLoaderTest1.class");

    }

}
